package com.ifudata.dvp.app.service.atom.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.ifudata.dvp.app.dao.factory.MapperFactory;
import com.ifudata.dvp.app.dao.mapper.base.bo.AppMenu;
import com.ifudata.dvp.app.dao.mapper.base.bo.AppMenuCriteria;
import com.ifudata.dvp.app.dao.mapper.base.bo.AppMenuCriteria.Criteria;
import com.ifudata.dvp.app.service.atom.interfaces.IAppMenuAtomSV;
import com.ifudata.dvp.sdk.util.CollectionUtil;

/**
 * 
 * @description <br>
 * @author libing <br>
 * @date 2017年9月18日 下午2:06:07<br>
 */
@Component
public class AppMenuAtomSVImpl implements IAppMenuAtomSV {

	@Override
	public List<AppMenu> queryAppMenus(Long parentId) {
		AppMenuCriteria example = new AppMenuCriteria();
		Criteria criteria = example.createCriteria();
		criteria.andStateEqualTo("1").andParentIdEqualTo(parentId);
		example.setOrderByClause("SORT");
		return MapperFactory.getAppMenuMapper().selectByExample(example);
	}

	@Override
	public List<AppMenu> queryAppMenus(List<Long> menuIdList) {
		AppMenuCriteria example = new AppMenuCriteria();
		Criteria criteria = example.createCriteria();
		if( CollectionUtil.isEmpty(menuIdList) ){
			menuIdList.add(null);
		}
		criteria.andStateEqualTo("1").andMenuIdIn(menuIdList);
		example.setOrderByClause("SORT");
		return MapperFactory.getAppMenuMapper().selectByExample(example);
	}

}